<?php

class Boletos_M extends I_Model {

    protected $_table_name = 'boletos';
    protected $_primary_key = 'ID';
    protected $_primary_filter = 'intval';
    protected $_order_by = 'ID';
    protected $_direction = 'DESC';
    public $rules = array();
    protected $_timestamps = FALSE;

    public function __construct() {
        parent::__construct();
    }
    /*
     * Override method 
     */
    function get($id = null){
    	
    	$this->db->select('cb.*,bnk.NOME_BANCO as BANCO,bl.*')
    	      ->from('boletos as bl')
    	      ->join('contas_bancarias as cb','cb.ID=bl.CONTA_ID')
    	      ->join('bancos as bnk','bnk.BANCO_ID=cb.BANCO_ID');
    	
    	if(!is_null($id)){
    		$this->db->where('bl.ID',$id);
    	}
    	
    	
    	$q = $this->db->get();
    	return is_null($id)  ? $q->result() : $q->row();
    }

}
